const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: ['require'],
  configureWebpack: {
    resolve: {
      fallback: {
        path: require.resolve('path-browserify'),
        os: require.resolve('os-browserify/browser'),
        crypto: require.resolve('crypto-browserify'),
        stream: require.resolve('stream-browserify'),
        zlib: require.resolve('browserify-zlib'),
        http: require.resolve('stream-http'),
        https: require.resolve('https-browserify'),
        constants: require.resolve('constants-browserify'),
        timers: require.resolve('timers-browserify')
      }
    },
    module: {
      rules: [
        {
          test: /\.node$/,
          use: 'node-loader'
        }
      ]
    },
    externals: {
      electron: 'require("electron")',
      fs: 'commonjs fs',
      child_process: 'commonjs child_process',
      net: 'commonjs net',
      tls: 'commonjs tls',
      dgram: 'commonjs dgram',
      dialog: 'commonjs dialog',
      shell: 'commonjs shell'
    }
  },
  devServer: {
    client: {
      overlay: false
    }
  },
  pluginOptions: {
    electronBuilder: {
      nodeIntegration: true,
      builderOptions: {
        'productName': 'ssl-auto-deploy',//生成exe的名字
        "appId": "com.gjxjl.sshtools",//包名
        "copyright": "Copyright © 2024 gjxjl.com",//版权信息
        "extraFiles": ["public/favicon.ico"],
        "directories": { // 输出文件夹
          "output": "electron_output",
        },
        "nsis": {
          "oneClick": false, // 是否一键安装
          "allowElevation": true, // 允许请求提升。若为false，则用户必须使用提升的权限重新启动安装程序。
          "allowToChangeInstallationDirectory": true, //是否允许修改安装目录
          "installerIcon": "public/favicon.ico",// 安装时图标
          "uninstallerIcon": "public/favicon.ico",//卸载时图标
          "installerHeaderIcon": "public/favicon.ico", // 安装时头部图标
          "createDesktopShortcut": true, // 是否创建桌面图标
          "createStartMenuShortcut": true,// 是否创建开始菜单图标
          "shortcutName": "ssl-tools", // 快捷方式名称
          "runAfterFinish": false,//是否安装完成后运行
        },
        "win": {
          "icon": "public/favicon.ico",//图标路径
          "target": [
            {
              "target": "nsis", //利用nsis制作安装程序
              "arch": [
                "x64", //64位
                // "ia32" //32位
              ]
            }
          ]
        },
        "linux": {
          "icon": "public/favicon.png",
          "target": [
            "AppImage"
          ],
          "category": "Utility"
        },
        "mac": {
          "category": "public.app-category.utilities",
          "icon": "public/favicon.ico",
          "target": [
            "dmg"
          ]
        }
      }
    }
  }
})
